var loopTime = 4;

$(function(){
	setTimeout(function(){
		$('#logo').animate({top:0},300);
		tea('#tea ul');		
	},500);
	$('#email').html('i'+'<a>@</a>'+'julying'+'.'+'com');
	inputStatus('.form .text,.form .textarea,.form .select');
	inputTitle('#yzmText');
	goTop('#goTop');
	pages('#pages');
	
});

function tea(obj){		
	var $tea = $(obj);
	$tea.find('li:first').show();
	$tea.animate({left:rand(450,550)},500 );
};

function pages(obj){
	var $obj = $(obj);
	if( $obj.attr('pagestatus') == 'false' )
		return ;
	var $current = $obj.find('span');
	var page = parseInt($current.text());
	var $prev = $obj.find('a').eq(1);
	var $next = $obj.find('a:last');
	
	if( !$prev.get(0) )
		return ;
	
	var prevPage  = $prev.attr('href').split('-')[2];
	prevPage = parseInt(prevPage);
	if( page == prevPage ||  page == 1)
		$prev.click(function(){
			return false;
		}).addClass('end').css('opacity',0.6);
	
	var nextPage  = $next.attr('href').split('-')[2];
	nextPage = parseInt(nextPage);
	if( page == nextPage) 
		$next.click(function(){
			return false;
		}).addClass('end').css('opacity',0.6);
};

function loading(obj,style){
	var $obj = $(obj);
	if( style == 'hide' )
		$obj.hide();
	else
		$obj.css('display','inline-block');	
}
